package com.edu.exam.enums.grading;

/**
 * 结果格式枚举
 */
public enum ResultFormat {
    JSON("JSON", "JSON格式"),
    XML("XML", "XML格式"),
    CSV("CSV", "CSV格式"),
    BINARY("BINARY", "二进制格式"),
    TEXT("TEXT", "文本格式"),
    COMPRESSED("COMPRESSED", "压缩格式"),
    CUSTOM("CUSTOM", "自定义格式");

    private final String code;
    private final String description;

    ResultFormat(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static ResultFormat fromCode(String code) {
        for (ResultFormat format : values()) {
            if (format.getCode().equals(code)) {
                return format;
            }
        }
        return JSON; // 默认返回JSON格式
    }
}